/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cardarus.operatingsystem.domain;

import java.util.Date;
import java.util.List;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

/**
 * This is a class corresponding to a Customer
 *
 * @author Javier Snaider
 */
@Entity
@DiscriminatorValue("CU")
public class Customer extends SystemUser{
    /**
     * Points in account 
     */
    @OneToOne(fetch=FetchType.EAGER)
    private RewardMembership pointsAccount;

    /**
     * Customer's pin
     */
    private String pin;

    /**
     * List of reminders
     */
    @OneToMany(mappedBy = "customer")
    private List<Reminder> reminders;
    
    /**
     * List of sales records
     */
    @OneToMany(mappedBy = "customer")
    private List<SalesTransaction> salesRecords;

    /**
     * Status to know whether customer has registered for rewards
     */
    private boolean registeredForRewards;
    /**
     * Status to know whether customer has registered for remind plan
     */
    @OneToOne(optional=true)
    private ReminderRegistration reminderRegistration;

    /** 
     * Customer's birthday
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date birthday;

    /**
     * The default constructor
     */
    public Customer() {
    }
/**
 * Constructor for Customer
 * @param id 
 * @param name 
 * @param familyName
 * @param phone
 * @param registeredForRewards
 * @param email
 * @param address
 * @param password
 * @param birthday
 * @param userName
 * @param pin
 */
    public Customer(int id, String name, String familyName, String phone, String email, String address, String userName, String password, String pin, boolean registeredForRewards, Date birthday) {
        super(id, name,  familyName,  phone,  email,  address,  userName,  password);
        this.pin = pin;
        this.registeredForRewards = registeredForRewards;
        this.birthday = birthday;
    }



    /**
     * returns the PIN
     * @return the PIN
     */
    public String getPin() {
        return pin;
    }

    /**
     * sets the PIN
     * @param pin
     */
    public void setPin(String pin) {
        this.pin = pin;
    }

    /**
     * returns the list of reminders for this Customer
     * @return the reminders
     */
    public List<Reminder> getReminders() {
        return reminders;
    }

    /**
     * sets the list of reminders for this Customer
     * @param reminders the reminders to set
     */
    public void setReminders(List<Reminder> reminders) {
        this.reminders = reminders;
    }

    /**
     * The list of sales
     * @return the salesRecords
     */
    public List<SalesTransaction> getSalesRecords() {
        return salesRecords;
    }

    /**
     * sets the list of sales
     * @param salesRecords the salesRecords to set
     */
    public void setSalesRecords(List<SalesTransaction> salesRecords) {
        this.salesRecords = salesRecords;
    }

    /**
     * true if the customer is registered for rewards
     * @return the registeredForRewards
     */
    public boolean isRegisteredForRewards() {
        return registeredForRewards;
    }

    /**
     * sets if the customer is registered for rewards
     * @param registeredForRewards the registeredForRewards to set
     */
    public void setRegisteredForRewards(boolean registeredForRewards) {
        this.registeredForRewards = registeredForRewards;
    }

    /**
     * returns the pointsAccount
     * @return the pointsAccount
     */
    public RewardMembership getPointsAccount() {
        return pointsAccount;
    }

    /**
     * sets the points account
     * @param pointsAccount the pointsAccount to set
     */
    public void setPointsAccount(RewardMembership pointsAccount) {
        this.pointsAccount = pointsAccount;
    }

    /**
     * gets the reminderRegistration
     * @return the reminderRegistration
     */
    public ReminderRegistration getReminderRegistration() {
        return reminderRegistration;
    }

    /**
     * sets the reminderRegistration
     * @param reminderRegistration the reminderRegistration to set
     */
    public void setReminderRegistration(ReminderRegistration reminderRegistration) {
        this.reminderRegistration = reminderRegistration;
    }

    /**
     * returns the Customer's birthday
     * @return the birthday
     */
    public Date getBirthday() {
        return birthday;
    }

    /**
     * sets the Customer's birthday
     * @param birthday the birthday to set
     */
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Customer{" + "pointsAccount=" + pointsAccount + "pin=" + pin + "reminders=" + reminders + "salesRecords=" + salesRecords + "registeredForRewards=" + registeredForRewards + "reminderRegistration=" + reminderRegistration + "birthday=" + birthday + '}';
    }

}
